<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>修改管理员信息</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
    <div class="box-body">
        <form role="form">
            <div class="form-group col-md-7" >
                <label>管理员名称</label>
                <input type="text" id="username" class="form-control" value="{$data.username}" placeholder="请输入名称...">
            </div>
            <div class="form-group col-md-7" >
                <label>登录用户名</label>
                <input type="text" id="loginid" class="form-control" value="{$data.loginid}" placeholder="请输入用户名...">
            </div>
            <div class="form-group col-md-7" >
                <label>登录密码</label>
                <input type="password" id="password" class="form-control" value="" >
            </div>
            <div class="form-group col-md-7" >
                <label>确认登陆密码</label>
                <input type="password" id="repassword" class="form-control" value="">
            </div>
            <div class="form-group col-md-7" >
                <label>所属部门</label>
                <input type="text" id="department" class="form-control" value="{$data.department}" placeholder="请输入部门...">
            </div>
            <input type="hidden" id="uid" value="{$data.id}">
            <div class="form-group col-md-7" >
                <div id="btn_edit" class="btn btn-info btn-flat pull-right">保存</div>
            </div>
        </form>
    </div>
    <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    $(function(){
        $('#btn_edit').click(function(){
            var _username = $('#username').val();
            var _loginid = $('#loginid').val();
            var _pwd = $('#password').val();
            var _repwd = $('#repassword').val();
            var _department = $('#department').val();
            var _id = $('#uid').val();
            if(_username == ''){
                layerAlert('请输入管理员名称');
                return false;
            }
            if(_loginid == ''){
                layerAlert('请输入登录用户名');
                return false;
            }
            if(_pwd != ''){
                if(_pwd !== _repwd){
                    layerAlert('两次密码输入不正确');
                    return false;
                }
            }
            if(_department == ''){
                layerAlert('请输入部门');
                return false;
            }
            $.ajax({
                cache: false,
                url:'{:url("user/doEditUser")}',
                data:{id:_id,username:_username,loginid:_loginid,pwd:_pwd,department:_department},
                type:'post',
                success:function(data){
                    if(data.code==0){
                        layerAlert('修改成功',function(){
                            parent.window.location.reload();
                            layerParentClose();
                        })
                    }else{
                        layerAlert('修改失败');
                    }
                },
                error:function(){
                    layerAlert('系统错误，请联系管理员');
                }
            })
        })
    })
</script>
</html>